using System;
using System.Collections;
using FwkLight.Persistence;
using NHibernate;

namespace FwkLight.Domain.Fetching
{
  class EntityMultiCriteriaFetcher<EntityType> : MultiCriteriaFetcher<EntityType>, IEntityMultiCriteriaFetcher<EntityType> where EntityType : class
  {
    public EntityType LoadEntity(ISession session)
    {
      //return LoadEntity(null);
      IList list = LoadDefinedList(session);

      EntityType entity = null;
      if (list.Count > 0)
        entity = list[0] as EntityType;

      return entity;
    }

    public void Clear()
    {
      _rootFetchingPart = null;
    }
  }
}